package cn.com.hhrcw.utils;

import lombok.Data;

/**
 * @program: stdss-boot-parent
 * @author: JD
 * @create: 2020-07-28 19:38
 **/
@Data
public class NumberUtils {
    private NumberUtils() {
    }

    public static boolean isEmpty(Number number) {
        return number == null || number.intValue() == 0 || number.longValue() == 0 || number.doubleValue() == 0;
    }

    public static boolean isNotEmpty(Number number) {
        return !isEmpty(number);
    }

    public static String toChinese(String string) {
        String[] s1 = {"零", "一", "二", "三", "四", "五", "六", "七", "八", "九"};
        String[] s2 = {"十", "百", "千", "万", "十", "百", "千", "亿", "十", "百", "千"};
        StringBuilder result = new StringBuilder();
        int n = string.length();
        for (int i = 0; i < n; i++) {
            int num = string.charAt(i) - '0';
            if (i != n - 1 && num != 0) {
                result.append(s1[num] + s2[n - 2 - i]);
            } else {
                result.append(s1[num]);
            }
        }
        return result.toString();

    }
}
